<!-- 
 *@Description: 漏斗图
 *@Author: ʟɪ ᴢʜɪ ᴛᴏɴɢ
 *@Date: 2022-10-17 16:24:15
-->
<template>
  <div id="funnel"></div>
</template>

<script>
export default {
  name: 'funnel',
  data() {
    return {};
  },
  mounted() {
    this.initEcharts();
  },
  methods: {
    initEcharts() {
      const myChart = this.$echarts.init(document.getElementById('funnel'));
      const option = {
        // title: {
        //   text: 'Funnel'
        // },
        // tooltip: {
        //   trigger: 'item',
        //   formatter: '{b} : {c}%'
        // },
        // toolbox: {
        //   feature: {
        //     dataView: { readOnly: false },
        //     restore: {},
        //     saveAsImage: {}
        //   }
        // },
        series: [
          {
            name: 'Funnel',
            type: 'funnel',
            left: '3%',
            top: 20,
            bottom: 20,
            width: '88%',
            min: 0,
            max: 100,
            minSize: '20%',
            maxSize: '100%',
            sort: 'descending',
            // gap: 2,
            label: {
              //   show: true,
              position: 'right',
              formatter: '{b} : {c}',
              color: '#fff',
              fontSize: 14
            },
            labelLine: {
              length: 10,
              lineStyle: {
                width: 1,
                type: 'solid'
              }
            },
            itemStyle: {
              borderColor: '#fff'
            },
            emphasis: {
              label: {
                fontSize: 20
              }
            },
            data: [
              { value: 56, name: '房建移交数量' },
              { value: 34, name: '市政移交数量' },
              { value: 10, name: '其他移交数量' },
              { value: 100, name: '移交总数量' }
            ]
          },
          {
            name: 'Funnel',
            type: 'funnel',
            left: '3%',
            top: 20,
            bottom: 20,
            width: '88%',
            min: 0,
            max: 100,
            minSize: '20%',
            maxSize: '100%',
            sort: 'descending',
            // gap: 2,
            label: {
              //   show: true,
              position: 'inside',
              formatter: params => {
                return params.percent * 2 + '%';
              }
            },
            labelLine: {
              length: 10,
              lineStyle: {
                width: 1,
                type: 'solid'
              }
            },
            itemStyle: {
              borderColor: '#fff'
            },
            emphasis: {
              label: {
                fontSize: 20
              }
            },
            data: [
              { value: 56, name: '房建移交数量' },
              { value: 34, name: '市政移交数量' },
              { value: 10, name: '其他移交数量' },
              { value: 100, name: '移交总数量' }
            ]
          }
        ]
      };
      myChart.setOption(option);
    }
  }
};
</script>

<style scoped>
#funnel {
  padding: 20px 0;
  width: 90%;
  height: 95%;
  margin: 10px 5%;
}
</style>
